<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Login</title>
        <%= stylesheet_link_tag "../javascripts/ext/resources/css/ext-all.css" %>
        <%= stylesheet_link_tag "/stylesheets/blue.css" %>
        <%= javascript_include_tag "/javascripts/ext/adapter/prototype/prototype.js" %>
        <%= javascript_include_tag "/javascripts/ext/adapter/prototype/scriptaculous.js" %>
        <%= javascript_include_tag "/javascripts/ext/adapter/prototype/effects.js" %>
        <%= javascript_include_tag "/javascripts/ext/adapter/prototype/ext-prototype-adapter.js" %>
        <!-- LIBS --><%= javascript_include_tag "/javascripts/ext/ext-base.js" %>
        <!-- ENDLIBS --><%= javascript_include_tag "/javascripts/ext/ext-all-debug.js" %>
        <%= javascript_include_tag "/javascripts/ext/build/locale/ext-lang-zh_CN.js" %>
    </head>
    <body>
        <div style="width:600px;">
            <div class="x-box-tl">
                <div class="x-box-tr">
                    <div class="x-box-tc">
                    </div>
                </div>
            </div>
            <div class="x-box-ml">
                <div class="x-box-mr">
                    <div class="x-box-mc">
                        <h3 style="margin-bottom:5px;">Search the Ext Forums</h3>
                        <input type="text" size="40" name="search" id="search" />
                        <div style="padding-top:2px;">
                            Live search requires a minimum of 2 characters.
                        </div>
                    </div>
                </div>
            </div>
            <div class="x-box-bl">
                <div class="x-box-br">
                    <div class="x-box-bc">
                    </div>
                </div>
            </div>
        </div>
        <script>
            Ext.onReady(function(){
            
                var ds = new Ext.data.Store({
                    //                    proxy: new Ext.data.ScriptTagProxy({
                    //                        url: 'http://extjs.com/forum/topics-remote.php'
                    //                    }),
                    proxy: new Ext.data.HttpProxy({
                        url: '/test/getLinker'
                    }),
                    reader: new Ext.data.JsonReader({
                        root: 'root',
                        totalProperty: 'totalProperty',
                        id: 'post_id'
                    }, [{
                        name: 'link_man',
                        mapping: 'link_man'
                    }, {
                        name: 'link_tel',
                        mapping: 'link_tel'
                    }])
                });
                
                // Custom rendering Template
                var resultTpl = new Ext.XTemplate('<tpl for="."><div class="search-item">', '<h3><span>{link_man}<br /></span>{link_tel}</h3>', '</div></tpl>');

                var search = new Ext.form.ComboBox({
                    store: ds,
                    displayField: 'title',
                    typeAhead: false,
                    loadingText: '正在查找...',
                    width: 570,
                    pageSize: 10,
                    hideTrigger: true,
                    tpl: resultTpl,
                    applyTo: 'search',
                    minChars: 2,
                    itemSelector: 'div.search-item',
                    onSelect: function(record){ // override default onSelect to do redirect
                        if (this.isExpanded()) {
                            this.collapse();
                        }//当点击时关闭combobox
                        //window.location = String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
                    }
                });
            });
        </script>
    </body>
</html>
<script>
    //                        if (loginForm.form.isValid()) {
    //                            Ext.MessageBox.alert('Error Message', loginForm.form.isValid);
    //                            loginForm.form.submit({
    //                                waitMsg: '系统正在登录...',
    //                                //reset: false,
    //                                failure: function(form, action){
    //                                    Ext.MessageBox.alert('Error Message', '登录失败');
    //                                    //Ext.MessageBox.alert('Error Message', "你们好");
    //                                },
    //                                success: function(form, action){
    //                                    Ext.MessageBox.alert('Confirm', '成功登录');
    //                                }
    //                            });
    //                        }
    //                        else {
    //                            Ext.MessageBox.alert('输入验证有错', '请输入必输选项');
    //                        }
    //Ext.MessageBox.alert('关于', '制作：奇思管理咨询有限公司<br><br>开发人员：Jerry,Mike');
</script>
